/*
 * SerialHelper.h
 *
 *  Created on: Feb 7, 2010
 *      Author: diqiu
 */

#ifndef SERIALIOHELPER_H_
#define SERIALIOHELPER_H_


#endif /* SERIALHELPER_H_ */

/* Initialize serial port
 * Setup baud rate, parity, and other flags
 * 	device: path to the device file
 * Returns file handler, or -1 on error
 */
int initPort(char *device);

/* Returns Baud rate of serial port */
int getBaudRate(int fd);

/* Read from serial port
 *  fd: file descriptor of serial port
 *  result: pointer holding to read result
 *  byte: number of bytes to read
 * Returns number of byte read
 */
int readPort(int fd, char* result, int bytes);

/* Write to serial port
 *  fd: file descritpor of serial port
 *  chars: pointer to characters to be written
 * Returns number of byte written
 */
int writePort(int fd, char* chars);
